import pytest
import requests
from pymysql import MySQLError

class A3mall:
    token = None
    def login(self):
        url =  "http://10.59.9.14:7003/api/public/login"
        data = {
            "username":"13811033962",
            "password":"123456"
        }
        headers = {
            "content-type":"application/json"
        }
        a = requests.post(url=url,json=data,headers=headers)
        self.token = a.json()['data']['token']
        print(a.json())

    def look(self):
        url = "http://10.59.9.14:7003/api/order/detail"
        date = {
            "id":"608036"
        }
        headers = {
            "auth-token":"Bearer "+f"{self.token}"
        }
        b = requests.get(url=url,params=date,headers=headers)
        print(b.json())

@pytest.mark.flaky(reruns=3, reruns_delay=2)
def test_a3mall():
    try:
        A3mall().login()
        A3mall().look()
    except MySQLError as f:
        print(f)
    except PermissionError as f:
        print(f)
    except Exception as f:
        print(f)